package com.zsr.eduservice.controller.front;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zsr.commonutils.R;
import com.zsr.eduservice.entity.EduCourse;
import com.zsr.eduservice.entity.EduTeacher;
import com.zsr.eduservice.entity.vo.SubjectNestedVo;
import com.zsr.eduservice.service.EduCourseService;
import com.zsr.eduservice.service.EduTeacherService;
import com.zsr.eduservice.service.impl.IndexFrontServiceImpl;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页查询接口
 * @author zsr
 * @date 2021/6/18 10:46
 */
@Api(tags={"前台首页接口"})
@RestController
@RequestMapping("/eduservice/indexfront")
//@CrossOrigin
public class IndexController {
    //（1）查询最新前4条讲师数据
    //（2）查询最新前8条课程数据
    @Autowired
    private IndexFrontServiceImpl indexFrontService;


    //查询前8条热门课程，查询前4条名师
    @GetMapping("index")
    public R index() {
        //查询前8条热门课程
        List<EduCourse> courseList = indexFrontService.getHotCourseList();

        //查询前4条名师
        List<EduTeacher> teacherList = indexFrontService.getFourTeacherList();

        //查询分类
        List<SubjectNestedVo> subjectList=indexFrontService.getSubjectNestedList(null);

        return R.ok().data("courseList",courseList).data("teacherList",teacherList).data("subjectList",subjectList);
    }

}
